package com.cskaoyan.bean;

import lombok.Data;

/**
 * @author stone
 * @date 2022/01/06 16:24
 */
@Data
public class BaseRespVo<T> {
    T data;
    String errmsg;
    int errno;

    public static <T> BaseRespVo ok(T data) {
        BaseRespVo baseRespVo = new BaseRespVo();
        baseRespVo.setData(data);
        return baseRespVo;
    }
    public static <T> BaseRespVo ok() {
        BaseRespVo baseRespVo = new BaseRespVo();
        baseRespVo.setErrno(0);
        baseRespVo.setErrmsg("成功");
        return baseRespVo;
    }

    public static <T> BaseRespVo invalidData(String msg) {
        BaseRespVo baseRespVo = new BaseRespVo();
        baseRespVo.setErrno(504);
        baseRespVo.setErrmsg(msg);
        return baseRespVo;
    }
    public static <T> BaseRespVo invalidData() {
        BaseRespVo baseRespVo = new BaseRespVo();
        baseRespVo.setErrno(504);
        baseRespVo.setErrmsg("更新数据已失效");
        return baseRespVo;
    }
    public static <T> BaseRespVo invalidParameter(String msg) {
        BaseRespVo baseRespVo = new BaseRespVo();
        baseRespVo.setErrno(400);
        baseRespVo.setErrmsg(msg);
        return baseRespVo;
    }
    public static <T> BaseRespVo unAuthc() {
        BaseRespVo baseRespVo = new BaseRespVo();
        baseRespVo.setErrno(502);
        baseRespVo.setErrmsg("认证失败");
        return baseRespVo;
    }

    public static BaseRespVo unlogin() {
        BaseRespVo baseRespVo = new BaseRespVo();
        baseRespVo.setErrno(700);
        baseRespVo.setErrmsg("账号密码不对");
        return baseRespVo;
    }

    public static BaseRespVo couponRecieved() {
        BaseRespVo baseRespVo = new BaseRespVo();
        baseRespVo.setErrno(740);
        baseRespVo.setErrmsg("优惠券已经领取过");
        return baseRespVo;
    }

    public static BaseRespVo couponNotFound() {
        BaseRespVo baseRespVo = new BaseRespVo();
        baseRespVo.setErrno(740);
        baseRespVo.setErrmsg("优惠券不存在");
        return baseRespVo;
    }
    public static <T> BaseRespVo shouldLogin() {
        BaseRespVo baseRespVo = new BaseRespVo();
        baseRespVo.setErrno(501);
        baseRespVo.setErrmsg("请先登录");
        return baseRespVo;
    }

    public static <T> BaseRespVo wrongParam() {
        BaseRespVo baseRespVo = new BaseRespVo();
        baseRespVo.setErrno(402);
        baseRespVo.setErrmsg("参数值不对");
        return baseRespVo;
    }

    public static <T> BaseRespVo phoneExist() {
        BaseRespVo baseRespVo = new BaseRespVo();
        baseRespVo.setErrno(705);
        baseRespVo.setErrmsg("手机号已存在");
        return baseRespVo;
    }

    public static <T> BaseRespVo usernameExist() {
        BaseRespVo baseRespVo = new BaseRespVo();
        baseRespVo.setErrno(704);
        baseRespVo.setErrmsg("用户名已存在");
        return baseRespVo;
    }

    public static <T>BaseRespVo wrongCode() {
        BaseRespVo baseRespVo = new BaseRespVo();
        baseRespVo.setErrno(703);
        baseRespVo.setErrmsg("验证码错误");
        return baseRespVo;
    }

    public static <T> BaseRespVo okAndSuccess(T data) {
        BaseRespVo baseRespVo = new BaseRespVo();
        baseRespVo.setData(data);
        baseRespVo.setErrmsg("成功");
        return baseRespVo;
    }

    public static BaseRespVo unauthorized() {
        BaseRespVo baseRespVo = new BaseRespVo();
        baseRespVo.setErrno(506);
        baseRespVo.setErrmsg("无操作权限");
        return baseRespVo;
    }
}

